﻿package mortal.game.net.command.group
{
    import Framework.MQ.*;
    import Message.BroadCast.*;
    import Message.Public.*;
    import mortal.game.cache.*;
    import mortal.game.mvc.*;
    import mortal.game.net.broadCast.*;
    import mortal.mvc.core.*;

    public class GroupMemberUpdateCommand extends BroadCastCall
    {

        public function GroupMemberUpdateCommand(param1:Object)
        {
            super(param1);
            return;
        }// end function

        override public function call(param1:MessageBlock) : void
        {
            var _loc_3:SAttributeUpdate = null;
            var _loc_2:* = param1.messageBase as SEntityUpdate;
            for each (_loc_3 in _loc_2.propertyUpdates)
            {
                
                this.entityInfoUpdate(_loc_3, _loc_2.entityId);
            }
            return;
        }// end function

        private function entityInfoUpdate(param1:SAttributeUpdate, param2:SEntityId) : void
        {
            var _loc_4:SGroupPlayer = null;
            var _loc_3:* = new Object();
            switch(param1.attribute.__value)
            {
                case EEntityAttribute._EAttributeGroupMemberOnline:
                {
                    _loc_3 = {type:EEntityAttribute._EAttributeGroupMemberOnline, value:param1.value, id:param2};
                    NetDispatcher.dispatchCmd(ServerCommand.updateTeamMateState, _loc_3);
                    break;
                }
                case EEntityAttribute._EAttributeGroupMemberAttacked:
                {
                    _loc_3 = {type:EEntityAttribute._EAttributeGroupMemberAttacked, value:param1.value, id:param2};
                    NetDispatcher.dispatchCmd(ServerCommand.updateTeamMateState, _loc_3);
                    break;
                }
                case EEntityAttribute._EAttributeSpaceId:
                {
                    _loc_3 = {type:EEntityAttribute._EAttributeSpaceId, value:param1.value, id:param2};
                    NetDispatcher.dispatchCmd(ServerCommand.updateTeamMateState, _loc_3);
                    break;
                }
                case EEntityAttribute._EAttributeCombat:
                {
                    _loc_4 = Cache.instance.group.getSGroupPlayerBySEntityId(param2);
                    if (_loc_4)
                    {
                        _loc_4.player.combat = param1.value;
                        _loc_4.player.entityId = param2;
                        NetDispatcher.dispatchCmd(ServerCommand.GroupPlayerInfoChange, null);
                    }
                    break;
                }
                case EEntityAttribute._EAttributeGroupMemberPosX:
                {
                    _loc_4 = Cache.instance.group.getSGroupPlayerBySEntityId(param2);
                    if (_loc_4)
                    {
                        _loc_4.point.x = param1.value;
                        NetDispatcher.dispatchCmd(ServerCommand.GroupPlayerPosMove, null);
                    }
                    break;
                }
                case EEntityAttribute._EAttributeGroupMemberPosY:
                {
                    _loc_4 = Cache.instance.group.getSGroupPlayerBySEntityId(param2);
                    if (_loc_4)
                    {
                        _loc_4.point.y = param1.value;
                        NetDispatcher.dispatchCmd(ServerCommand.GroupPlayerPosMove, null);
                    }
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

    }
}
